package cn.com.note.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

import com.blankj.utilcode.util.LogUtils;
import com.google.gson.Gson;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import cn.com.note.R;
import cn.com.note.utils.DataListBean;
import cn.com.note.utils.GetJsonDataUtil;
import cn.com.note.utils.UpLoadDateRequest;
import cn.com.note.view.MenuSend;

/**
 * 单选按钮 Demo
 * Created by SunFuLin on 2019/1/4.
 */

public class RadioViewActivity extends AppCompatActivity implements View.OnClickListener{

    MenuSend menuSend1,menuSend2,menuSend3,menuSend4;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_radio_view);
        init();
        initView();
        initData();
        LogUtils.log(Log.INFO,"内容：","RadioViewActivity 页启动");
    }

    private void init() {

    }

    private void initView() {
        menuSend1=(MenuSend) findViewById(R.id.menu_send_1);
        menuSend2=(MenuSend) findViewById(R.id.menu_send_2);
        menuSend3=(MenuSend) findViewById(R.id.menu_send_3);
        menuSend4=(MenuSend) findViewById(R.id.menu_send_4);


        menuSend1.updateUi(ContextCompat.getDrawable(this,R.drawable.send_scaner),"发货扫描");
        menuSend2.updateUi(ContextCompat.getDrawable(this,R.drawable.code_delete),"按数码删除");
        menuSend3.updateUi(ContextCompat.getDrawable(this,R.drawable.product_delete),"按产品删除");
        menuSend4.updateUi(ContextCompat.getDrawable(this,R.drawable.do_delete),"按单据删除");

        findViewById(R.id.bt_analysis).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //image_base64
                String json=GetJsonDataUtil.getJson(RadioViewActivity.this,"Image.json");
                try {
                    JSONObject s=new JSONObject(json);
                    if(s!=null){
                       String baseImg= s.getString("image_base64");
                        List<DataListBean> imagetUpload = new ArrayList<DataListBean>();
                        DataListBean dateBean = new DataListBean();
                        dateBean.setPicture(baseImg);
                        imagetUpload.add(dateBean);
                        imagetUpload.add(dateBean);
                        imagetUpload.add(dateBean);
                        imagetUpload.add(dateBean);
                        imagetUpload.add(dateBean);
                        imagetUpload.add(dateBean);
                        imagetUpload.add(dateBean);
                        imagetUpload.add(dateBean);
                        imagetUpload.add(dateBean);
                        imagetUpload.add(dateBean);
                        UpLoadDateRequest fristLoginRequest = new UpLoadDateRequest();
                        fristLoginRequest.setAccountName("12653865");
                        fristLoginRequest.setFactoryid("121321");
                        fristLoginRequest.setPhoneNumber("869233032465038");
                        fristLoginRequest.setData(imagetUpload);
                        String data = new Gson().toJson(fristLoginRequest);
                        Log.d("数据内容：",data);
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        });
    }

    private void initData() {
    }

    @Override
    public void onClick(View v) {

    }
}
